home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 July / Disc 2 / PCU0703CD2.iso / entertn / demos / files / ron.exe / ai / scripts / defensive.bhs < prev    next >
Encoding:
Text File  |  2003-04-29  |  26.8 KB  |  765 lines

  1. //Mark Sobota
  2. //John Hawkins
  3. //defensive.bhs
  4. //rush script
  5. //works for each nation
  6.  
  7. labels {
  8.   BLOCK_ON_THIS = 1,
  9.   DONT_BLOCK_ON_THIS,
  10.   SCRIPT_DONE,
  11. }
  12.  
  13. include "aibestbuildlibrary.bhs"
  14.  
  15. int ai defensive (int who, ref int step, int boom_vs_rush, int num_loops)
  16. {
  17.   if ((num_cities(who) < 1)&&(num_type_with_queued(who, "Citizen") < 1)) return SCRIPT_DONE;
  18.  
  19.   my_capital = find_city_with_num(who, 1);
  20.  
  21.   if (was_city_attacked(who, "", -1)||was_city_raided(who, "", -1)) {
  22.     if ((num_type_with_queued(who, "Barracks") < 1)&&(have_tech(who, "The Art of War"))) {
  23.       if (place_building_with_cost(who, "Barracks", my_capital) > 0) return SCRIPT_DONE;
  24.       else return BLOCK_ON_THIS;
  25.     }
  26.     else return SCRIPT_DONE;
  27.   }
  28.  
  29.   int return_value = BLOCK_ON_THIS;
  30.   static int prev_step0 = 0;
  31.   static int prev_step1 = 0;
  32.   static int prev_step2 = 0;
  33.   static int prev_step3 = 0;
  34.   static int prev_step4 = 0;
  35.   static int prev_step5 = 0;
  36.   static int prev_step6 = 0;
  37.   static int prev_step7 = 0;
  38.   static int needed_citizens0 = 0;
  39.   static int needed_citizens1 = 0;
  40.   static int needed_citizens2 = 0;
  41.   static int needed_citizens3 = 0;
  42.   static int needed_citizens4 = 0;
  43.   static int needed_citizens5 = 0;
  44.   static int needed_citizens6 = 0;
  45.   static int needed_citizens7 = 0;
  46.   static int rush_build0 = rand_int(1, 10);
  47.   static int rush_build1 = rand_int(1, 10);
  48.   static int rush_build2 = rand_int(1, 10);
  49.   static int rush_build3 = rand_int(1, 10);
  50.   static int rush_build4 = rand_int(1, 10);
  51.   static int rush_build5 = rand_int(1, 10);
  52.   static int rush_build6 = rand_int(1, 10);
  53.   static int rush_build7 = rand_int(1, 10);
  54.   static int timer_started0 = 0;
  55.   static int timer_started1 = 0;
  56.   static int timer_started2 = 0;
  57.   static int timer_started3 = 0;
  58.   static int timer_started4 = 0;
  59.   static int timer_started5 = 0;
  60.   static int timer_started6 = 0;
  61.   static int timer_started7 = 0;
  62.   static int fishermen_total0 = 0;
  63.   static int fishermen_total1 = 0;
  64.   static int fishermen_total2 = 0;
  65.   static int fishermen_total3 = 0;
  66.   static int fishermen_total4 = 0;
  67.   static int fishermen_total5 = 0;
  68.   static int fishermen_total6 = 0;
  69.   static int fishermen_total7 = 0;
  70.   int old_step;
  71.   who_nation = find_nation(who); //get player nation
  72.   static int needed_techs = get_techs_per_age(who);
  73.   int player_age = age(who);
  74.   static int wood_camp = 0;
  75.   static int wood_camp_1 = 0;
  76.   static int max_woodcutters = 0;
  77.   int needed_citizens = 0;
  78.   static int build_merchant = 0;
  79.   int timer_started = 0;
  80.   int j = 0;
  81.   int k = 0;
  82.   int build_true = 0;
  83.   int new_city = 0;
  84.   int citizen_id = 0;
  85.   int caravan_lim = num_cities(who) * (num_cities(who) - 1) / 2;
  86.   int fishermen_cap = 4;
  87.   int fishermen_total = 0;
  88.   int large_conquest_start = 0;
  89.  
  90.   int sea_map = 0;
  91.  
  92.   int rush_build = 0;
  93.  
  94.   ///ghetto array///
  95.   switch (who-1) {
  96.   case 0:
  97.     old_step = prev_step0;
  98.     needed_citizens = needed_citizens0;
  99.     rush_build = rush_build0;
  100.     timer_started = timer_started0;
  101.     fishermen_total = fishermen_total0;
  102.     break;
  103.   case 1:
  104.     old_step = prev_step1;
  105.     needed_citizens = needed_citizens1;
  106.     rush_build = rush_build1;
  107.     timer_started = timer_started1;
  108.     fishermen_total = fishermen_total1;
  109.     break;
  110.   case 2:
  111.     old_step = prev_step2;
  112.     needed_citizens = needed_citizens2;
  113.     rush_build = rush_build2;
  114.     timer_started = timer_started2;
  115.     fishermen_total = fishermen_total2;
  116.     break;
  117.   case 3:
  118.     old_step = prev_step3;
  119.     needed_citizens = needed_citizens3;
  120.     rush_build = rush_build3;
  121.     timer_started = timer_started3;
  122.     fishermen_total = fishermen_total3;
  123.     break;
  124.   case 4:
  125.     old_step = prev_step4;
  126.     needed_citizens = needed_citizens4;
  127.     rush_build = rush_build4;
  128.     timer_started = timer_started4;
  129.     fishermen_total = fishermen_total4;
  130.     break;
  131.   case 5:
  132.     old_step = prev_step5;
  133.     needed_citizens = needed_citizens5;
  134.     rush_build = rush_build5;
  135.     timer_started = timer_started5;
  136.     fishermen_total = fishermen_total5;
  137.     break;
  138.   case 6:
  139.     old_step = prev_step6;
  140.     needed_citizens = needed_citizens6;
  141.     rush_build = rush_build6;
  142.     timer_started = timer_started6;
  143.     fishermen_total = fishermen_total6;
  144.     break;
  145.   case 7:
  146.     old_step = prev_step7;
  147.     needed_citizens = needed_citizens7;
  148.     rush_build = rush_build7;
  149.     timer_started = timer_started7;
  150.     fishermen_total = fishermen_total7;
  151.     break;
  152.   default:
  153.     old_step = 0;
  154.     needed_citizens = 0;
  155.     break;
  156.   }
  157.  
  158.   //turns off ancient age rush for certain rules
  159.   if ((get_rush_rules() > 0)||(is_victory_economic())||(is_victory_musical_chairs())||(is_victory_tech_race())||(is_victory_territory())||(is_victory_wonder())||(is_victory_score())) {
  160.     rush_build = 20;
  161.   }
  162.  
  163.   ////water mapstyles at the moment: Atlantic Sea Power, Nile Delta, British Isles, Warring States, New World, East Indies
  164.   ////East Meets West, Colonial Powers, Mediterranean, Australian Outback
  165.   ////not at the moment: Great Lakes?, African Watering Hole?
  166.   if ((get_mapstyle() == "Atlantic Sea Power")||(get_mapstyle() == "Nile Delta")||(get_mapstyle() == "British Isles")||(get_mapstyle() == "Warring States")||(get_mapstyle() == "New World")||(get_mapstyle() == "East Indies")) {
  167.     sea_map = 1;
  168.   }
  169.   else if ((get_mapstyle() == "East Meets West")||(get_mapstyle() == "Colonial Powers")||(get_mapstyle() == "Mediterranean")||(get_mapstyle() == "Australian Outback")) {
  170.     sea_map = 1;
  171.   }
  172.   else sea_map = 0;
  173.  
  174.   my_second_city = find_city_with_num(who, 2);
  175.   my_third_city = find_city_with_num(who, 3);
  176.  
  177.   if (is_conquest_scenario()) {
  178.     size = get_starting_town_size(who);
  179.     if (step == 1) {
  180.       if (size == 0) step = 1; //nomad
  181.       else if (size == 1) step = 2;
  182.       else if (size == 2) step = 6; //standard
  183.       else large_conquest_start = 1;
  184.     }
  185.     else if (size > 2) large_conquest_start = 1;
  186.   }
  187.   if (large_conquest_start > 0) {
  188.     if ((age(who) > 0)&&(age(who) < 5)) {
  189.       //build 2 farms, university, mine, 2nd woodcutter, research military 1, build barracks, build stable, 2 heavy, 2 light, 1 archer
  190.       switch (step) {
  191.       case 1:
  192.         if(!have_tech(who, "The Art of War")) {
  193.           if (research_tech_with_cost(who, "The Art of War") > 0) step++;
  194.         }
  195.         else step++;
  196.         return BLOCK_ON_THIS;
  197.         break;
  198.       case 2:
  199.         train_unit_with_cost(who, 5, "Citizen");
  200.         if (have_tech(who, "The Art of War")) step+=2;
  201.         else step++;
  202.         return BLOCK_ON_THIS;
  203.         break;
  204.       case 3:
  205.         if (num_type_with_queued(who, "Barracks") < 1) {
  206.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Barracks", my_capital);
  207.           else if (num_cities(who) == 2) place_building_upgrade_with_cost(who, "Barracks", my_second_city);
  208.           else if (num_cities(who) == 3) place_building_upgrade_with_cost(who, "Barracks", my_third_city);
  209.         }
  210.         if (num_type_with_queued(who, "Stable") < 1) {
  211.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Stable", my_capital);
  212.           else if (num_cities(who) == 2) place_building_upgrade_with_cost(who, "Stable", my_second_city);
  213.           else if (num_cities(who) == 3) place_building_upgrade_with_cost(who, "Stable", my_third_city);
  214.         }
  215.         if ((num_type_with_queued(who, "Barracks") > 0)&&(num_type_with_queued(who, "Stable") > 0)) step++;
  216.         return BLOCK_ON_THIS;
  217.         break;
  218.       case 4:
  219.         if (num_type_with_queued(who, "Tower") < num_cities(who)) {
  220.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Tower", my_capital);
  221.           else if (num_cities(who) == 2) {
  222.             place_building_upgrade_with_cost(who, "Tower", my_second_city);
  223.             place_building_upgrade_with_cost(who, "Tower", my_capital);
  224.           }
  225.           else if (num_cities(who) == 3) {
  226.             place_building_upgrade_with_cost(who, "Tower", my_third_city);
  227.             place_building_upgrade_with_cost(who, "Tower", my_second_city);
  228.             place_building_upgrade_with_cost(who, "Tower", my_capital);            
  229.           }
  230.         }
  231.         else if (num_type(who, "Market") < 1) return SCRIPT_DONE;
  232.         if (num_type_with_queued(who, "Tower") > num_cities(who)-1) return SCRIPT_DONE;
  233.         return BLOCK_ON_THIS;
  234.         break;
  235.       default:
  236.         return SCRIPT_DONE;
  237.       }
  238.     }
  239.     else if (age(who) > 4) {
  240.       switch (step) {
  241.       case 1:
  242.         if(!have_tech(who, "The Art of War")) {
  243.           if (research_tech_with_cost(who, "The Art of War") > 0) step++;
  244.         }
  245.         else step++;
  246.         return BLOCK_ON_THIS;
  247.         break;
  248.       case 2:
  249.         train_unit_with_cost(who, 5, "Citizen");
  250.         if (have_tech(who, "The Art of War")) step+=2;
  251.         else step++;
  252.         return BLOCK_ON_THIS;
  253.         break;
  254.       case 3:
  255.         if (num_type_with_queued(who, "Barracks") < 1) {
  256.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Barracks", my_capital);
  257.           else if (num_cities(who) == 2) place_building_upgrade_with_cost(who, "Barracks", my_second_city);
  258.           else if (num_cities(who) == 3) place_building_upgrade_with_cost(who, "Barracks", my_third_city);
  259.         }
  260.         if (num_type_with_queued(who, "Auto Plant") < 1) {
  261.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Auto Plant", my_capital);
  262.           else if (num_cities(who) == 2) place_building_upgrade_with_cost(who, "Auto Plant", my_second_city);
  263.           else if (num_cities(who) == 3) place_building_upgrade_with_cost(who, "Auto Plant", my_third_city);
  264.         }
  265.         if ((num_type_with_queued(who, "Barracks") > 0)&&(num_type_with_queued(who, "Auto Plant") > 0)) step++;
  266.         return BLOCK_ON_THIS;
  267.         break;
  268.       case 4:
  269.         if (num_type_with_queued(who, "Stockade") < num_cities(who)) {
  270.           if (num_cities(who) == 1) place_building_upgrade_with_cost(who, "Tower", my_capital);
  271.           else if (num_cities(who) == 2) {
  272.             place_building_upgrade_with_cost(who, "Tower", my_second_city);
  273.             place_building_upgrade_with_cost(who, "Tower", my_capital);
  274.           }
  275.           else if (num_cities(who) == 3) {
  276.             place_building_upgrade_with_cost(who, "Tower", my_third_city);
  277.             place_building_upgrade_with_cost(who, "Tower", my_second_city);
  278.             place_building_upgrade_with_cost(who, "Tower", my_capital);
  279.           }
  280.         }
  281.         else if (num_type(who, "Market") < 1) return SCRIPT_DONE;
  282.         if (num_type_with_queued(who, "Tower") > num_cities(who)-1) return SCRIPT_DONE;
  283.         return BLOCK_ON_THIS;
  284.         break;
  285.       default:
  286.         return SCRIPT_DONE;
  287.       }
  288.     }
  289.   }
  290.  
  291.   //checks to see what the settings are and initializes the script starting point to the appropriate place
  292.   if (step == 1) {
  293.     if (get_starting_resources(who) > 4 || num_cities(who) > 1) {
  294.       return SCRIPT_DONE;
  295.     }
  296.     size = get_starting_town_size(who);
  297.     if (size == 0) step = 1; //nomad
  298.     else if (size == 1) step = 2;
  299.     else if (size >= 2) step = 6; //standard
  300.     else return SCRIPT_DONE;
  301.   }
  302.  
  303.   //trains citizens if the need isn't currently fulfilled
  304.   if (needed_citizens > 0) train_unit_with_need(who, needed_citizens, "Citizen");
  305.  
  306.   ////builds needed number of caravans and merchants
  307.   if (num_type(who, "Market") >= 1) {
  308.     if (num_type_with_queued(who, "Caravan") < caravan_lim) {
  309.       train_unit_with_cost(who, 1, "Caravan");  
  310.     }
  311.     for (j = num_type_with_queued(who, "Merchant"); ((j < 3)&&(j < num_rare_resources_seen(who))); j++) {
  312.       if (train_unit_with_cost(who, 1, "Merchant") < 1) break;
  313.     }
  314.   }
  315.  
  316.   ////builds farms until limit is reached
  317.   ////check to see map style and place dock at second city and start 2 boats up if appropriate
  318.   if (step > 16) {
  319.     if ((who_nation == "Germans")&&(get_is_no_nation_powers() < 1)) {
  320.       if (num_city_buildings(who, my_capital, "Granary", 1) < 1) {
  321.         place_building_with_cost(who, "Granary", my_capital);
  322.       }
  323.       if (num_city_buildings(who, my_capital, "Lumber Mill", 1) < 1) {
  324.         place_building_with_cost(who, "Lumber Mill", my_capital);
  325.       }
  326.     }
  327.     if (sea_map > 0) {
  328.       if (num_type_with_queued(who, "Dock") < 1) {
  329.         place_dock(who); //tries to place a dock near a city in this order: Capital, City Two, City Three
  330.       }
  331.       else {
  332.         //train two initial fish herders
  333.         if (fishermen_total < 2) {
  334.           if (train_unit_with_cost(who, 1, "Fishermen") > 0) fishermen_total++;
  335.         }
  336.       }
  337.     }
  338.     //fill up first two cities with farms
  339.     if (place_farm(who) > 0) old_step = 0;
  340.   }
  341.   //after market is built, train as many fish herders as possible before classical age
  342.   if ((fishermen_total < fishermen_cap)&&(step > 20)&&(step < 27)&&(num_type(who, "Dock") > 0)) {
  343.     if (train_unit_with_cost(who, 1, "Fishermen") > 0) fishermen_total++;
  344.   }
  345.  
  346.   //if population is approaching the limit we need to research the first military tech
  347.   if (population(who) >= 23 && (!have_tech(who, "The Art of War"))) {
  348.     research_tech_with_cost(who, "The Art of War");
  349.   }
  350.  
  351.   //Ancient Age Rush part, only happens a third of the time
  352.   if ((step == 6)&&(rush_build < 4)&&(!is_conquest_scenario())&&(sea_map < 1)&&(get_starting_town_size(who) > 1)) {
  353.     old_step = 0;
  354.     if(!have_tech(who, "The Art of War")) {
  355.       while (num_city_buildings(who, my_capital, "Farm", 1) < 5) {
  356.         if (place_building_with_cost(who, "Farm", my_capital) < 1) break;
  357.       }
  358.       if (research_tech_with_cost(who, "The Art of War") > 0) {
  359.         needed_citizens = 9;
  360.         train_unit_with_need(who, needed_citizens, "Citizen");
  361.         return BLOCK_ON_THIS;
  362.       }
  363.       else return BLOCK_ON_THIS;
  364.     }
  365.     else {
  366.       if (num_type_with_queued(who, "Barracks") < 1) {
  367.         place_building_with_cost(who, "Barracks", my_capital);
  368.         return BLOCK_ON_THIS;
  369.       }
  370.       else if (num_type(who, "Barracks") > 0) {
  371.         //build 4 heavies and one light
  372.         if (num_type_with_queued(who, "Hoplites") < 4) {
  373.           train_unit_with_cost(who, 1, "Hoplites");
  374.           return BLOCK_ON_THIS;
  375.         }
  376.         else if (num_type_with_queued(who, "Slingers") < 1) {
  377.           train_unit_with_cost(who, 1, "Slingers");
  378.           return BLOCK_ON_THIS;
  379.         }
  380.         else {
  381.           rush_build = 25;
  382.           return_value = BLOCK_ON_THIS;
  383.         }
  384.       }
  385.       else return BLOCK_ON_THIS;
  386.     }
  387.   }
  388.  
  389.   ////check to see if script is hanging
  390.   if ((step == old_step)&&(timer_started < 1)) {
  391.     set_timer(who, 240);
  392.     timer_started = 1;
  393.   }
  394.   if (step != old_step) {
  395.     stop_timer(who);
  396.     timer_started = 0;
  397.   }
  398.   
  399.   if (timer_expired(who)) {
  400.     return SCRIPT_DONE;
  401.   }
  402.  
  403.   for (i = 0; i < num_loops; i++) {
  404.  
  405.     if (old_step != step) old_step = step;
  406.  
  407.     switch (step) {
  408.     ////Nomad Setup Procedure/////
  409.     case 1: //place City (nomad)
  410.       old_step = 0;
  411.       if (num_type_with_queued(who, "Small City") < 1) place_city_with_cost(who);
  412.       if (find_inactive_build(who, "Small City")) {
  413.         new_city = find_inactive_build(who, "Small City");
  414.         if (building_started(who, new_city)) step++;
  415.       }
  416.       return_value = BLOCK_ON_THIS;
  417.       break;
  418.     case 2: //place Woodcutter's Camp at capital
  419.       old_step = 0;
  420.       new_city = find_inactive_build(who, "Small City");
  421.       if (new_city > 0) {
  422.         for (j = 0; j < num_type(who, "Citizen"); j++) {
  423.           citizen_id = find_unit(who, "Citizen");
  424.           citizen_repair_order(who, citizen_id, new_city);
  425.         }
  426.       }
  427.       if (place_building_with_cost(who, "Woodcutter's Camp", my_capital) > 0) step++;
  428.       else if ((my_capital > -1) && (can_pay_cost(who, "Woodcutter's Camp") > 0)) return SCRIPT_DONE;
  429.       return_value = BLOCK_ON_THIS;
  430.       break;
  431.     case 3: //place 3 farms at capital
  432.       old_step = 0;
  433.       for (j = num_type_with_queued(who, "Farm"); j < 3; j++) {
  434.         if (place_building_with_cost(who, "Farm", my_capital) < 1) break;
  435.       }
  436.       if (num_type_with_queued(who, "Farm") == 3) step++;
  437.       return_value = BLOCK_ON_THIS;
  438.       break;
  439.     case 4: //build up to 5 peasants
  440.       needed_citizens = 5;
  441.       train_unit_with_need(who, needed_citizens, "Citizen");
  442.       step++;
  443.       return_value = BLOCK_ON_THIS;
  444.       break;
  445.     case 5: //build a library
  446.       old_step = 0;
  447.       if (place_building_with_cost(who, "Library", my_capital) > 0) step++;
  448.       return_value = BLOCK_ON_THIS;
  449.       break;
  450.     ////End Nomad Setup Procedure/////
  451.     case 6: //research first science tech
  452.       old_step = 0;
  453.       if (have_tech(who, "Written Word")) step++;
  454.         else if (research_tech_with_cost(who, "Written Word") > 0) step++;
  455.       else if (at_least_type(who, 75, "Wealth") < 1) {
  456.         if (sea_map > 0) return SCRIPT_DONE;
  457.         else step++;
  458.       }
  459.       return_value = BLOCK_ON_THIS;
  460.       break; 
  461.     case 7: //place farm #4 
  462.       if (num_city_buildings(who, my_capital, "Farm", 1) < 4) {
  463.         if (place_building_with_cost(who, "Farm", my_capital) > 0) {
  464.           if ((age(who) > 0) || ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1))) step++;
  465.           else step+=2;
  466.         }
  467.       }
  468.       else {
  469.         if ((age(who) > 0) || ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1))) step++;
  470.         else step+=2;
  471.       }
  472.       return_value = BLOCK_ON_THIS;
  473.       break;
  474.     case 8: //place university at capital
  475.       if (num_type(who, "University") < 1) {
  476.         if (place_building_with_cost(who, "University", my_capital) > 0) step++;
  477.       }
  478.       else step++;
  479.       return_value = BLOCK_ON_THIS;
  480.       break;
  481.     case 9: //research first Civics tech
  482.       if (num_cities(who) > 1) return SCRIPT_DONE;
  483.       else if (have_tech(who, "City State")) step++;
  484.       else if (research_tech_with_cost(who, "City State")) step++;
  485.       return_value = BLOCK_ON_THIS;
  486.       break;
  487.     case 10: //build 6th-8th citizen
  488.       train_unit_with_cost(who, 3, "Citizen");
  489.       step++;
  490.       return_value = BLOCK_ON_THIS;
  491.       break;
  492.     case 11: //place second_city
  493.       if (have_tech(who, "City State")) {
  494.         if (num_cities(who) < 2) {
  495.           if (city_placement(who) > 0) step++;
  496.           else if (can_pay_cost(who, "Small City")) step++;
  497.         }
  498.         else step++;
  499.       }
  500.       return_value = BLOCK_ON_THIS;
  501.       break;
  502.     case 12: //build 9th-10th citizen
  503.       needed_citizens = 10;
  504.       train_unit_with_need(who, needed_citizens, "Citizen");
  505.       step++;
  506.       return_value = BLOCK_ON_THIS;
  507.       break;
  508.     case 13: //place farm #5
  509.       if (num_type_with_queued(who, "Farm") < 5) {
  510.         place_building_with_cost(who, "Farm", my_capital);
  511.         step++;
  512.       }
  513.       else step++;
  514.       return_value = BLOCK_ON_THIS;
  515.       break;
  516.     case 14: //place a second woodcutter's camp if 2nd is 5 or less
  517.       if (place_woodcutter(who) > 0) step++;
  518.       else if (can_pay_cost(who, "Woodcutter's Camp") > 0) step++;
  519.       return_value = BLOCK_ON_THIS;
  520.       break;
  521.     case 15: //research first commerce tech
  522.       if (research_tech_with_cost(who, "Barter") > 0){
  523.         if ((age(who) > 0) || ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1))) step++;
  524.         else step+=2;
  525.       }
  526.       return_value = BLOCK_ON_THIS;
  527.       break;
  528.     case 16: // build 1 scholars (if possible)
  529.       if (num_type(who, "University") >= 1) {
  530.         if (train_unit_with_cost(who, 1, "Scholar") > 0) step++;
  531.       }
  532.       else step++;
  533.       return_value = BLOCK_ON_THIS;
  534.       break;
  535.     case 17: //build 12th-16th citizen
  536.       needed_citizens = 16;
  537.       train_unit_with_need(who, needed_citizens, "Citizen");
  538.       if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)) {
  539.         step+=2;
  540.       }
  541.       else step++;
  542.       return_value = BLOCK_ON_THIS;
  543.       break;
  544.     case 18: //research second commerce tech
  545.       if (num_cities(who) < 2) return SCRIPT_DONE;
  546.       if (research_tech_with_cost(who, "Coinage") >= 0) old_step = 0;
  547.         if (have_tech(who, "Coinage")) step++;
  548.       return_value = BLOCK_ON_THIS;
  549.       break;
  550.     case 19: //train citizen 17-20, place third city if bantu
  551.       needed_citizens = 20;
  552.       train_unit_with_need(who, needed_citizens, "Citizen");
  553.       if (num_cities(who) < 2) { //checks to see if the second city wasn't placed initially
  554.         if (sea_map > 0) { //places second city on island(in theory) if second city hasn't been placed
  555.           if (num_type(who, "Dock") > 0) {
  556.             if (city_placement(who) > 0) step++;
  557.             else if (can_pay_cost(who, "Small City") > 0) step++;
  558.           }
  559.         }
  560.         else step++;
  561.       }
  562.       else {
  563.         if ((who_nation == "Bantu")&&(get_is_no_nation_powers() < 1)) {
  564.           if (num_cities(who) < 3) {
  565.             if (sea_map > 0) {
  566.               if (num_type(who, "Dock") > 0) {
  567.                 if (city_placement(who) > 0) step++;
  568.                 else if (can_pay_cost(who, "Small City")) step++;
  569.               }
  570.               else if ((num_type_with_queued(who, "Dock") < 1)&&(can_pay_cost(who, "Dock") > 0)) {
  571.                 if (city_placement(who) > 0) step++;
  572.                 else if (can_pay_cost(who, "Small City")) step++;
  573.               }
  574.             }
  575.             else if (city_placement(who) > 0) step++;
  576.             else if (can_pay_cost(who, "Small City")) step++;
  577.           }
  578.           else step++;
  579.         }
  580.         else {
  581.           if ((who_nation == "Nubians")&&(get_is_no_nation_powers() < 1)) {
  582.             step+=2;
  583.           }
  584.           else step++;
  585.         }
  586.       }
  587.       return_value = BLOCK_ON_THIS;
  588.       break;
  589.     case 20: //build a market in capital
  590.       if (num_type(who, "Market") == 0) {
  591.         if (have_tech(who, "Barter")) {
  592.           if (place_building_with_cost(who, "Market", my_capital) > 0) {
  593.             if ((age(who) > 0) || ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1))) step++;
  594.             else step+=2;
  595.           }
  596.         }
  597.       }
  598.       else {
  599.         if ((age(who) > 0) || ((who_nation == "Greeks")&&(get_is_no_nation_powers() < 1))) step++;
  600.         else step+=2;
  601.       }
  602.       return_value = BLOCK_ON_THIS;
  603.       break;
  604.     case 21: //build scholars 2 and 3
  605.       if (num_type(who, "University") >= 1) {
  606.         if (train_unit_with_cost(who, 2, "Scholar") > 0) step++;
  607.       }
  608.       else step++;
  609.       return_value = BLOCK_ON_THIS;
  610.       break;
  611.     case 22: //train citizen 21
  612.       needed_citizens = 21;
  613.       train_unit_with_need(who, needed_citizens, "Citizen");
  614.       step++;
  615.       return_value = BLOCK_ON_THIS;
  616.       break;      
  617.     case 23: //build 3rd woodcutter's camp
  618.       max_woodcutters = 0;
  619.       for (wc = num_type(who, "Woodcutter's Camp"); wc > 0; wc--) {
  620.         wood_camp = find_build(who, "Woodcutter's Camp");
  621.         max_woodcutters += max_workers_at_building(who, wood_camp);
  622.       }
  623.       if (max_woodcutters < 12) {
  624.         if (find_inactive_build(who, "Woodcutter's Camp") > 0) step++;
  625.         else { //only try this once
  626.           place_woodcutter(who);
  627.           step++;
  628.         }
  629.       }
  630.       else step++;
  631.       return_value = BLOCK_ON_THIS;
  632.       break;    
  633.     case 24: //train citizen 22
  634.       needed_citizens = 22;
  635.       train_unit_with_need(who, needed_citizens, "Citizen");
  636.       if (!have_tech(who, "The Art of War")) step++;
  637.       else {
  638.         if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)) step+=3;
  639.         else step+=2;
  640.       }
  641.       return_value = BLOCK_ON_THIS;
  642.       break;
  643.       case 25: //research first military tech
  644.       if (!have_tech(who, "The Art of War")) {
  645.         if (research_tech_with_cost(who, "The Art of War")) {
  646.           if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)) {
  647.             step+=2;
  648.           }
  649.           else step++;
  650.         }
  651.       }
  652.       else {
  653.         if ((who_nation == "British")&&(get_is_no_nation_powers() < 1)) {
  654.           step+=2;
  655.         }
  656.         else step++;
  657.       }
  658.         return_value = BLOCK_ON_THIS;
  659.         break;   
  660.     case 26: //train citizens 23-25
  661.       needed_citizens = 25;
  662.       train_unit_with_need(who, needed_citizens, "Citizen");
  663.       step++;
  664.       return_value = BLOCK_ON_THIS;
  665.       break;
  666.     case 27: //barracks
  667.       if (have_tech(who, "The Art of War")) {
  668.         if (place_building_with_cost(who, "Barracks", my_second_city) > 0) step++;
  669.         else if (place_building_with_cost(who, "Barracks", my_capital) > 0) step++;
  670.       }
  671.       return_value = BLOCK_ON_THIS;
  672.       break;
  673.     case 28: //tower
  674.       if (place_building_with_cost(who, "Tower", my_second_city) > 0) step++;
  675.       else if (place_building_with_cost(who, "Tower", my_capital) > 0) step++;
  676.       return_value = BLOCK_ON_THIS;
  677.       break;
  678.     case 29: //research classical age
  679.       if (is_conquest_scenario()) return SCRIPT_DONE;
  680.       else if (needed_techs <= 3) {
  681.         if (age(who) > 0) return SCRIPT_DONE;
  682.         else if (research_tech_with_cost(who, "Classical Age") > 0) {
  683.           return SCRIPT_DONE;
  684.         }
  685.       }
  686.       else return SCRIPT_DONE;
  687.       return_value = BLOCK_ON_THIS;
  688.       break;
  689.     default:
  690.       return_value = SCRIPT_DONE;
  691.       break;
  692.     }
  693.   }
  694.  
  695.   ///ghetto array///
  696.   switch (who-1) {
  697.   case 0:
  698.     prev_step0 = old_step;
  699.     needed_citizens0 = needed_citizens;
  700.     rush_build0 = rush_build;
  701.     timer_started0 = timer_started;
  702.     fishermen_total0 = fishermen_total;
  703.     break;
  704.   case 1:
  705.     prev_step1 = old_step;
  706.     needed_citizens1 = needed_citizens;
  707.     rush_build1 = rush_build;
  708.     timer_started1 = timer_started;
  709.     fishermen_total1 = fishermen_total;
  710.     break;
  711.   case 2:
  712.     prev_step2 = old_step;
  713.     needed_citizens2 = needed_citizens;
  714.     rush_build2 = rush_build;
  715.     timer_started2 = timer_started;
  716.     fishermen_total2 = fishermen_total;
  717.     break;
  718.   case 3:
  719.     prev_step3 = old_step;
  720.     needed_citizens3 = needed_citizens;
  721.     rush_build3 = rush_build;
  722.     timer_started3 = timer_started;
  723.     fishermen_total3 = fishermen_total;
  724.     break;
  725.   case 4:
  726.     prev_step4 = old_step;
  727.     needed_citizens4 = needed_citizens;
  728.     rush_build4 = rush_build;
  729.     timer_started4 = timer_started;
  730.     fishermen_total4 = fishermen_total;
  731.     break;
  732.   case 5:
  733.     prev_step5 = old_step;
  734.     needed_citizens5 = needed_citizens;
  735.     rush_build5 = rush_build;
  736.     timer_started5 = timer_started;
  737.     fishermen_total5 = fishermen_total;
  738.     break;
  739.   case 6:
  740.     prev_step6 = old_step;
  741.     needed_citizens6 = needed_citizens;
  742.     rush_build6 = rush_build;
  743.     timer_started6 = timer_started;
  744.     fishermen_total6 = fishermen_total;
  745.     break;
  746.   case 7:
  747.     prev_step7 = old_step;
  748.     needed_citizens7 = needed_citizens;
  749.     rush_build7 = rush_build;
  750.     timer_started7 = timer_started;
  751.     fishermen_total7 = fishermen_total;
  752.     break;
  753.   default:
  754.     old_step = 0;
  755.     needed_citizens = 0;
  756.     rush_build = 0;
  757.     break;
  758.   }
  759.   return return_value;
  760. }
  761.  
  762.  
  763.  
  764.  
  765.